package com.devunion.salon.persistence;

import javax.persistence.*;
import java.sql.Date;

/**
 *
 CREATE TABLE theday (
    id INT AUTO_INCREMENT NOT NULL,
    start DECIMAL,
    amex DECIMAL,
    mastercard DECIMAL,
    visa DECIMAL,
    creditCard DECIMAL,
    giftCard DECIMAL,
    expenses DECIMAL,
    totalCash DECIMAL,
    endOfTheDay DECIMAL,
    ajustment DECIMAL,
    putInEnvelop DECIMAL,
    created DATE,
    ended CHAR(1) ASCII,
   PRIMARY KEY (id)
 ) ENGINE = InnoDB ROW_FORMAT = DEFAULT;

 *
 * @author Viktar Liaskovich
 */

@Entity
@Table(name = "the_day")
public class Day extends BasePersistentObject {
    @Column(name = "start", nullable = true)
    private Float start;

    @Column(name = "amex", nullable = true)
    private Float amex;

    @Column(name = "mastercard", nullable = true)
    private Float mastercard;

    @Column(name = "visa", nullable = true)
    private Float visa;

    @Column(name = "giftCard", nullable = true)
    private Float giftCard;

    @Column(name = "expenses", nullable = true)
    private Float expenses;

    @Column(name = "totalCash", nullable = true)
    private Float totalCash;

    @Column(name = "endOfTheDay", nullable = true)
    private Float endOfTheDay;

    @Column(name = "ajustment", nullable = true)
    private Float ajustment;

    @Column(name = "putInEnvelop", nullable = true)
    private Float putInEnvelop;

    @Column(name = "created", nullable = true)
    private Date created;

    @Column(name = "ended", nullable = true)
    private Boolean ended;

    @ManyToOne(cascade = {CascadeType.ALL})
    private Login login;

    @ManyToOne(cascade = {CascadeType.ALL})
    private Location location;

    public Float getStart() {
        return start;
    }

    public void setStart(Float start) {
        this.start = start;
    }

    public Float getAmex() {
        return amex;
    }

    public void setAmex(Float amex) {
        this.amex = amex;
    }

    public Float getMastercard() {
        return mastercard;
    }

    public void setMastercard(Float mastercard) {
        this.mastercard = mastercard;
    }

    public Float getVisa() {
        return visa;
    }

    public void setVisa(Float visa) {
        this.visa = visa;
    }

    public Float getGiftCard() {
        return giftCard;
    }

    public void setGiftCard(Float giftCard) {
        this.giftCard = giftCard;
    }

    public Float getExpenses() {
        return expenses;
    }

    public void setExpenses(Float expenses) {
        this.expenses = expenses;
    }

    public Float getTotalCash() {
        return totalCash;
    }

    public void setTotalCash(Float totalCash) {
        this.totalCash = totalCash;
    }

    public Float getEndOfTheDay() {
        return endOfTheDay;
    }

    public void setEndOfTheDay(Float endOfTheDay) {
        this.endOfTheDay = endOfTheDay;
    }

    public Float getAjustment() {
        return ajustment;
    }

    public void setAjustment(Float ajustment) {
        this.ajustment = ajustment;
    }

    public Float getPutInEnvelop() {
        return putInEnvelop;
    }

    public void setPutInEnvelop(Float putInEnvelop) {
        this.putInEnvelop = putInEnvelop;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Boolean getEnded() {
        return ended;
    }

    public void setEnded(Boolean ended) {
        this.ended = ended;
    }

    public Float getTotalCard() {

        float result = 0;

        if (amex != null) {
            result += amex;
        }

        if (mastercard != null) {
            result += mastercard;
        }

        if (visa != null) {
            result += visa;
        }

        return result;
    }

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }
}
